<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Vertx::NetSocket
  
    &mdash; Ruby API Doc
  
</title>

  <link rel="stylesheet" href="../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../';
  framesUrl = "../frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">
  
    <a href="../_index.html">Index (N)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../Vertx.html" title="Vertx (module)">Vertx</a></span></span>
     &raquo; 
    <span class="title">NetSocket</span>
  

  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">
  
    <a class="full_list_link" id="class_list_link"
        href="../class_list.html">
      Class List
    </a>
  
    <a class="full_list_link" id="method_list_link"
        href="../method_list.html">
      Method List
    </a>
  
    <a class="full_list_link" id="file_list_link"
        href="../file_list.html">
      File List
    </a>
  
</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Vertx::NetSocket
  
  
  
</h1>

<dl class="box">
  
    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName">Object</span>
      
        <ul class="fullTree">
          <li>Object</li>
          
            <li class="next">Vertx::NetSocket</li>
          
        </ul>
        <a href="#" class="inheritanceTree">show all</a>
      
      </dd>
    
  
  
    
  
    
      <dt class="r2">Includes:</dt>
      <dd class="r2"><span class='object_link'><a href="ReadStream.html" title="Vertx::ReadStream (module)">ReadStream</a></span>, <span class='object_link'><a href="WriteStream.html" title="Vertx::WriteStream (module)">WriteStream</a></span></dd>
      
    
  
  
  
    <dt class="r1 last">Defined in:</dt>
    <dd class="r1 last">src/main/api_shim/core/net.rb</dd>
  
</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">
    NetSocket is a socket-like abstraction used for reading from or writing
to TCP connections.

  </div>
</div>
<div class="tags">
  
<p class="tag_title">Author:</p>
<ul class="author">
  
    <li>
      
      
      
      
        
        <div class='inline'><a href="http://tfox.org" target="_parent" title="Tim Fox">Tim Fox</a></div>
      
    </li>
  
</ul>

</div>






  
    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">
      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#close-instance_method" title="#close (instance method)">- (Object) <strong>close</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Close the socket.</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#close_handler-instance_method" title="#close_handler (instance method)">- (Object) <strong>close_handler</strong>(&amp;hndlr) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Set a closed handler on the socket.</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#local_address-instance_method" title="#local_address (instance method)">- (Object) <strong>local_address</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Return the Addrinfo to which the local end of the socket is bound.</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#remote_address-instance_method" title="#remote_address (instance method)">- (Object) <strong>remote_address</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Return the Addrinfo to which the remote end of the socket is bound.</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#send_file-instance_method" title="#send_file (instance method)">- (Object) <strong>send_file</strong>(file_path) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Tell the kernel to stream a file directly from disk to the outgoing connection, bypassing userspace altogether
(where supported by the underlying operating system. This is a very efficient way to stream files..</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#write_handler_id-instance_method" title="#write_handler_id (instance method)">- (Object) <strong>write_handler_id</strong> </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>When a NetSocket is created it automatically registers an event handler with the system.</div></span>
  
</li>

      
        <li class="public ">
  <span class="summary_signature">
    
      <a href="#write_str-instance_method" title="#write_str (instance method)">- (Object) <strong>write_str</strong>(str, enc = &quot;UTF-8&quot;) </a>
    

    
  </span>
  
  
  
  
  
  
  

  
    <span class="summary_desc"><div class='inline'>Write a String to the socket.</div></span>
  
</li>

      
    </ul>
  


  
  
  
  
  
  
  
  
  <h3 class="inherited">Methods included from <span class='object_link'><a href="ReadStream.html" title="Vertx::ReadStream (module)">ReadStream</a></span></h3>
  <p class="inherited"><span class='object_link'><a href="ReadStream.html#data_handler-instance_method" title="Vertx::ReadStream#data_handler (method)">#data_handler</a></span>, <span class='object_link'><a href="ReadStream.html#end_handler-instance_method" title="Vertx::ReadStream#end_handler (method)">#end_handler</a></span>, <span class='object_link'><a href="ReadStream.html#exception_handler-instance_method" title="Vertx::ReadStream#exception_handler (method)">#exception_handler</a></span>, <span class='object_link'><a href="ReadStream.html#pause-instance_method" title="Vertx::ReadStream#pause (method)">#pause</a></span>, <span class='object_link'><a href="ReadStream.html#resume-instance_method" title="Vertx::ReadStream#resume (method)">#resume</a></span></p>

  
  
  
  
  
  
  
  
  <h3 class="inherited">Methods included from <span class='object_link'><a href="WriteStream.html" title="Vertx::WriteStream (module)">WriteStream</a></span></h3>
  <p class="inherited"><span class='object_link'><a href="WriteStream.html#drain_handler-instance_method" title="Vertx::WriteStream#drain_handler (method)">#drain_handler</a></span>, <span class='object_link'><a href="WriteStream.html#exception_handler-instance_method" title="Vertx::WriteStream#exception_handler (method)">#exception_handler</a></span>, <span class='object_link'><a href="WriteStream.html#write-instance_method" title="Vertx::WriteStream#write (method)">#write</a></span>, <span class='object_link'><a href="WriteStream.html#write_queue_full%3F-instance_method" title="Vertx::WriteStream#write_queue_full? (method)">#write_queue_full?</a></span>, <span class='object_link'><a href="WriteStream.html#write_queue_max_size-instance_method" title="Vertx::WriteStream#write_queue_max_size (method)">#write_queue_max_size</a></span>, <span class='object_link'><a href="WriteStream.html#write_queue_max_size%3D-instance_method" title="Vertx::WriteStream#write_queue_max_size= (method)">#write_queue_max_size=</a></span></p>


  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>

    
      <div class="method_details first">
  <h3 class="signature first" id="close-instance_method">
  
    - (<tt>Object</tt>) <strong>close</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Close the socket

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


205
206
207</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 205</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_close identifier id'>close</span>
  <span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_close identifier id'>close</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="close_handler-instance_method">
  
    - (<tt>Object</tt>) <strong>close_handler</strong>(&amp;hndlr) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Set a closed handler on the socket.

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>hndlr</span>
      
      
        <span class='type'>(<tt>Block</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>A block to be used as the handler</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


191
192
193
194</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 191</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_close_handler identifier id'>close_handler</span><span class='lparen token'>(</span><span class='bitand op'>&amp;</span><span class='rubyid_hndlr identifier id'>hndlr</span><span class='rparen token'>)</span>
  <span class='rubyid_@close_handler ivar id'>@close_handler</span> <span class='assign token'>=</span> <span class='rubyid_hndlr identifier id'>hndlr</span>
  <span class='rubyid_self self kw'>self</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="local_address-instance_method">
  
    - (<tt>Object</tt>) <strong>local_address</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Return the Addrinfo to which the local end of the socket is bound

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


227
228
229
230
231
232</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 227</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_local_address identifier id'>local_address</span>
  <span class='rubyid_if if kw'>if</span> <span class='notop op'>!</span><span class='rubyid_@local_addr ivar id'>@local_addr</span>
    <span class='rubyid_@local_addr ivar id'>@local_addr</span> <span class='assign token'>=</span> <span class='rubyid_Addrinfo constant id'>Addrinfo</span><span class='dot token'>.</span><span class='rubyid_tcp identifier id'>tcp</span><span class='lparen token'>(</span><span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_localAddress identifier id'>localAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_getAddress identifier id'>getAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_getHostAddress identifier id'>getHostAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_localAddress identifier id'>localAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_getPort identifier id'>getPort</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='rubyid_end end kw'>end</span>
  <span class='rubyid_@local_addr ivar id'>@local_addr</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="remote_address-instance_method">
  
    - (<tt>Object</tt>) <strong>remote_address</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Return the Addrinfo to which the remote end of the socket is bound

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


218
219
220
221
222
223</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 218</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_remote_address identifier id'>remote_address</span>
  <span class='rubyid_if if kw'>if</span> <span class='notop op'>!</span><span class='rubyid_@remote_addr ivar id'>@remote_addr</span>
    <span class='rubyid_@remote_addr ivar id'>@remote_addr</span> <span class='assign token'>=</span> <span class='rubyid_Addrinfo constant id'>Addrinfo</span><span class='dot token'>.</span><span class='rubyid_tcp identifier id'>tcp</span><span class='lparen token'>(</span><span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_remoteAddress identifier id'>remoteAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_getAddress identifier id'>getAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_getHostAddress identifier id'>getHostAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='comma token'>,</span> <span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_remoteAddress identifier id'>remoteAddress</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='dot token'>.</span><span class='rubyid_getPort identifier id'>getPort</span><span class='lparen token'>(</span><span class='rparen token'>)</span><span class='rparen token'>)</span>
  <span class='rubyid_end end kw'>end</span>
  <span class='rubyid_@remote_addr ivar id'>@remote_addr</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="send_file-instance_method">
  
    - (<tt>Object</tt>) <strong>send_file</strong>(file_path) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Tell the kernel to stream a file directly from disk to the outgoing connection, bypassing userspace altogether
(where supported by the underlying operating system. This is a very efficient way to stream files.

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>file_path.</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>Path to file to send.</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


199
200
201
202</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 199</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_send_file identifier id'>send_file</span><span class='lparen token'>(</span><span class='rubyid_file_path identifier id'>file_path</span><span class='rparen token'>)</span>
  <span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_sendFile identifier id'>sendFile</span><span class='lparen token'>(</span><span class='rubyid_file_path identifier id'>file_path</span><span class='rparen token'>)</span>
  <span class='rubyid_self self kw'>self</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="write_handler_id-instance_method">
  
    - (<tt>Object</tt>) <strong>write_handler_id</strong> 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    When a NetSocket is created it automatically registers an event handler with the system. The address of that
handler is given by <span class='object_link'><a href="#write_handler_id-instance_method" title="Vertx::NetSocket#write_handler_id (method)">#write_handler_id</a></span>.
Given this ID, a different event loop can send a buffer to that event handler using the event bus. This
allows you to write data to other connections which are owned by different event loops.

  </div>
</div>
<div class="tags">
  

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


213
214
215</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 213</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_write_handler_id identifier id'>write_handler_id</span>
  <span class='rubyid_@write_handler_id ivar id'>@write_handler_id</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
      <div class="method_details ">
  <h3 class="signature " id="write_str-instance_method">
  
    - (<tt>Object</tt>) <strong>write_str</strong>(str, enc = &quot;UTF-8&quot;) 
  

  

  
</h3><div class="docstring">
  <div class="discussion">
    Write a String to the socket. The handler will be called when the string has actually been written to the wire.

  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">
  
    <li>
      
        <span class='name'>str.</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>The string to write.</div>
      
    </li>
  
    <li>
      
        <span class='name'>enc.</span>
      
      
        <span class='type'>(<tt>String</tt>)</span>
      
      
      
        &mdash;
        <div class='inline'>The encoding to use.</div>
      
    </li>
  
</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


184
185
186
187</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'src/main/api_shim/core/net.rb', line 184</span>

<span class='rubyid_def def kw'>def</span> <span class='rubyid_write_str identifier id'>write_str</span><span class='lparen token'>(</span><span class='rubyid_str identifier id'>str</span><span class='comma token'>,</span> <span class='rubyid_enc identifier id'>enc</span> <span class='assign token'>=</span> <span class='string val'>&quot;UTF-8&quot;</span><span class='rparen token'>)</span>
  <span class='rubyid_@j_del ivar id'>@j_del</span><span class='dot token'>.</span><span class='rubyid_write identifier id'>write</span><span class='lparen token'>(</span><span class='rubyid_str identifier id'>str</span><span class='comma token'>,</span> <span class='rubyid_enc identifier id'>enc</span><span class='rparen token'>)</span>
  <span class='rubyid_self self kw'>self</span>
<span class='rubyid_end end kw'>end</span>
</pre>
    </td>
  </tr>
</table>
</div>
    
  </div>

</div>

    <div id="footer">
  Generated on Wed Jul 17 20:30:34 2013 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.6.1 (ruby-1.9.3).
</div>

  </body>
</html>